package com.fanli.bigdata.mytest

/**
 * Created by liangdong.wu on 2016/12/20.
 */
object RegexDemo {
  def main(args: Array[String]): Unit = {
    dtReg("""[02/Nov/2016:17:43:54 +0800]""")
  }

  def varnishReg():Unit={
    val log = """111.19.32.224 - 104444908 [02/Nov/2016:17:43:54 +0800] GET http://fun.fanli.com/ HTTP/1.1 200 80 "http://m.fanli.com/taobao" "Fanli/5.4.2.11 (HUAWEI PLK-TL01H; Android 6.0; zh_CN; ID:2-104444908-67732835577999-12-0)" 0.011075258 miss pass 2168972125.2841786673.892491704 2168972125.2841786673.2733802942 21195b -"""
    val varnish_pattern = """(?:-|[^-]*) (?:-|[^ ]*) ([^ ]*) \[([^\]]*)\] [^ ]* ([^ ]*) [^ ]* [^ ]* (?:-|\d*) \"([^ ]*)\" \"([\s\S]*?)\" [\s\S]*""".r
    val agent_pattern="""(?:[\s\S]*?)ID:[0-9]-([0-9]{0,})-[0-9]{0,}-[\s\S]*""".r
    val varnish_pattern(user_id, timeStr,path,refer, agent) = log
    println(user_id +"\t"+ timeStr +"\t" + agent)
    val agent_pattern(agent_uid) = agent
    println(agent_uid)
  }

  def dtReg(str:String):Unit={
    val pattern="""\[([^\]]*)\]""".r
    val pattern(p1) = str
    println(p1)
  }
}
